package org.jeecg.modules.api.factory;

import org.jeecg.modules.api.vo.CreateOrderForm;
import org.jeecg.modules.equipment.entity.Equipment;
import org.jeecg.modules.order.entity.Order;
import org.springframework.stereotype.Component;

import java.util.UUID;

/**
 * @author: Dean
 * @since: 2019/10/6
 */
@Component
public class OrderFactory {
    public Order toOrderEntity(CreateOrderForm orderForm, Equipment equipment){
        Order order = new Order();
        order.setEquipmentId(equipment.getId());
        order.setMerchantId(equipment.getMerchantId());
        order.setDeviceIp(orderForm.getDevice_ip());
        order.setDeviceNo(orderForm.getDevice_no());
        order.setGoodsDesc(orderForm.getGoods_desc());
        order.setAmount(orderForm.getTotal_fee());
        order.setStatus(0);
        order.setOrderNo(UUID.randomUUID().toString());
        return order;
    }
}
